/*
  学习目标：setState第二个参数的使用👎
  1. 不会合并setState, 会多次操作dom
  2. 容易写出回调地域
*/

import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };

  handleAdd = () => {
    this.setState({ count: this.state.count + 1 }, () => {
      this.setState({ count: this.state.count + 2 }, () => {
        this.setState({ count: this.state.count + 3 });
      });
    });
  };

  render() {
    const { count } = this.state;
    console.log('render  ----->  ');

    return (
      <div>
        App
        <h1>{count}</h1>
        <button onClick={this.handleAdd}>点我</button>
      </div>
    );
  }
}
